//
//  RCSettingVC.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-6-23.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCSettingVC.h"
#import <QuartzCore/QuartzCore.h>
#import "CommonDefines.h"
#import "UIColor-Expanded.h"
#import "GloableEngineService.h"
#import "AppDelegate.h"

#define kBGImageFile             @"image_discount_cell_bg.png"
#define kLineImageFile           @"image_line_type3.png"
#define kArrowImageFile          @"image_setting_arrow.png"

@interface RCSettingVC ()

@end

@implementation RCSettingVC

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void)loadView{
    [super loadView];
    self.titleLabelText = @"系统设置";
    self.navigationItem.titleView = [self createTitleView];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIView *settingView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 70)];
    NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:kBGImageFile];
    UIImage *bgImage = [UIImage imageWithContentsOfFile:filePath];
    settingView.layer.contents = (id)bgImage.CGImage;
    
    UILabel *mainLabel = [[UILabel alloc]initWithFrame:CGRectMake(14, 17, 250, 16)];
    mainLabel.backgroundColor = [UIColor clearColor];
    mainLabel.textColor = [UIColor colorWithHex:0xff505050];
    mainLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:16];
    [settingView addSubview:mainLabel];
    
    UILabel *littleLabel = [[UILabel alloc]initWithFrame:CGRectMake(14, 41,250, 12)];
    littleLabel.backgroundColor = [UIColor clearColor];
    littleLabel.textColor = [UIColor colorWithHex:0xff979797];
    littleLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:12];
    [settingView addSubview:littleLabel];
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(299, 30, 7, 10)];
    imageView.backgroundColor = [UIColor clearColor];
    NSString *arrowPath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:kArrowImageFile];
    [imageView setImage:[UIImage imageWithContentsOfFile:arrowPath]];
    [settingView addSubview:imageView];
    [imageView release];
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 320, 70)];
    button.backgroundColor = [UIColor clearColor];
    [button addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [settingView addSubview:button];
    [button release];
    
    if ([GloableEngineService sharedInstance].GPSEnabled) {
        mainLabel.text = @"关闭GPS（卫星定位）";
        littleLabel.text = @"关闭GPS会降低定位精度";
    }else{
        mainLabel.text = @"开启GPS（卫星定位）";
        littleLabel.text = @"开启GPS可以提高定位精度";
    }
    
    [mainLabel release];
    [littleLabel release];
    
    [self.viewContainer addSubview:settingView];
    [settingView release];
    
    
    
	// Do any additional setup after loading the view.
}

-(void)buttonClicked{
    if ([GloableEngineService sharedInstance].GPSEnabled) {
        [RCAppDelegate alertWithCustomizeString:@"需要到系统设置的隐私中关闭定位服务"];
    }else{
        [RCAppDelegate alertWithCustomizeString:@"需要到系统设置的隐私中开启定位服务"];
    }
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
